<template>
  <div id="app">
     <kindeditor id="editor_id" height="500px" width="100%" :content.sync="editorText"
      :afterChange="afterChange()"
      :afterCreate="afterCreate()"
      :loadStyleMode="false"
      @on-content-change="onContentChange"></kindeditor>
  </div>
</template>

<script>
import kindeditor from './kindeditor.vue'
import {WordPaster} from '../../static/WordPaster/js/w'
import {zyCapture} from '../../static/zyCapture/z'
import {zyOffice} from '../../static/zyOffice/js/o'
import '../../static/WordPaster/css/w.css'
import '../../static/zyCapture/z.css'
import '../../static/zyOffice/css/o.css'
import '../../static/layer-v3.1.1/layer/layer'
import '../../static/layer-v3.1.1/layer/theme/default/layer.css'
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'WordPaster for vue KindEditor',
      // 双向同步的变量
      editorText: '<p>泽优全平台内容发布解决方案 for vue2-cli-KindEditor</p><p>泽优Word一键粘贴控件（WordPaster）</p><p>泽优全平台截屏控件（zyCapture）</p><p>泽优Office文档转换服务（zyOffice）</p>',
      // content-change 事件回掉改变的对象
      editorTextCopy: ''
    }
  },
  components: {kindeditor},
  mounted () {
  },
  methods: {
    onContentChange (val) {
      this.editorTextCopy = val
    },
    afterChange () {
    },
    afterCreate () {
      // 初始化
      WordPaster.getInstance({
        // 上传接口：http://www.ncmem.com/doc/view.aspx?id=d88b60a2b0204af1ba62fa66288203ed
        PostUrl: 'http://localhost:8891/upload.aspx',
        // 为图片地址增加域名：http://www.ncmem.com/doc/view.aspx?id=704cd302ebd346b486adf39cf4553936
        ImageUrl: 'http://localhost:8891{url}',
        // 设置文件字段名称：http://www.ncmem.com/doc/view.aspx?id=c3ad06c2ae31454cb418ceb2b8da7c45
        FileFieldName: 'file',
        // 提取图片地址：http://www.ncmem.com/doc/view.aspx?id=07e3f323d22d4571ad213441ab8530d1
        ImageMatch: '',
        event:{
          dataReady:function(e){
            //e.word,
            //e.imgs:tag1,tag2,tag3
            console.log(e.imgs)
          }
        }
      })

      // zyCapture
      zyCapture.getInstance({
        config: {
          PostUrl: 'http://localhost:8891/upload.aspx',
          ImageUrl: 'http://localhost:8891{url}',
          FileFieldName: 'file',
          Fields: { uname: 'test' }
        }
      })

      // zyoffice，
      // 使用前请在服务端部署zyoffice，
      // http://www.ncmem.com/doc/view.aspx?id=82170058de824b5c86e2e666e5be319c
      zyOffice.getInstance({
        word: 'http://localhost:13710/zyoffice/word/convert',
        wordExport: 'http://localhost:13710/zyoffice/word/export',
        pdf: 'http://localhost:13710/zyoffice/pdf/upload'
      })

      WordPaster.getInstance().SetEditor(this)
      window.zyCapture.setEditor(this)
      window.zyOffice.SetEditor(this)
      // var self = this;
      // //自定义 Ctrl + V 事件。
      // KindEditor.ctrl(self.edit.doc, 'V', function () { WordPaster.getInstance().Paste(); });
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
